// example_text_file_writer.cpp : Defines the entry point for the console application.
//

/*
// Sync Routine

#include "stdafx.h"
#include <Inklude/ikCUdpServer.h>

using namespace Inklude;

int _tmain(int argc, _TCHAR* argv[])
{   
    ikCUdpClient client;
    client.Initialize(15575);

    char *buffer = new char[MSG_SIZE];

    while (true)
    {
        if (client.Receive(buffer, MSG_SIZE) == MSG_SIZE)
        {
            printf(buffer);
        }
    }

	return 0;
}
*/


// ASync Routine
#include "stdafx.h"
#include <functional>
#include <Windows.h>
#include <Inklude/ikCUdpServer.h>

using namespace Inklude;


static const int MSG_SIZE = 60000;


int _tmain(int argc, _TCHAR* argv[])
{
    std::shared_ptr<ikCUdpClient> client(new ikCUdpClient);
    Inklude::ikAsyncHandler recvComplete;
    ikCUdpClient::AsyncHandler recvHeader;
    
    client->Initialize(15575);

    char *buffer = new char[MSG_SIZE];

    recvComplete.reset(new std::function<void(size_t)>([&](size_t recvData)
    {
        printf("%d\n", recvData);
        client->AsyncReceive(buffer, MSG_SIZE, recvComplete);
    }));

    client->AsyncReceive(buffer, MSG_SIZE, recvComplete);

    while (true)
    {
        Sleep(1000);
    }

	return 0;
}
